package com.zhanghp.class040;


import static com.zhanghp.class040.Code01_NQueens.*;
import static com.zhanghp.class040.Code02_NQueens.*;
/**
 * @author zhanghp
 * @since 2024/7/1 18:26
 */
public class Compare_Code01_Code02 {

    public static void main(String[] args) {
        Code01_NQueens normal = new Code01_NQueens();
        Code02_NQueens bitOperation = new Code02_NQueens();
        int n = 14;
        long start, end;
        System.out.println("测试开始");
        System.out.println("解决" + n + "皇后问题");
        start = System.currentTimeMillis();
        System.out.println("方法1答案 : " + normal.totalNQueens(n));
        end = System.currentTimeMillis();
        System.out.println("方法1运行时间 : " + (end - start) + " 毫秒");

        start = System.currentTimeMillis();
        System.out.println("方法2答案 : " + bitOperation.totalNQueens(n));
        end = System.currentTimeMillis();
        System.out.println("方法2运行时间 : " + (end - start) + " 毫秒");
        System.out.println("测试结束");

        System.out.println("=======");
        System.out.println("只有位运算的版本，才能10秒内跑完16皇后问题的求解过程");
        start = System.currentTimeMillis();
        int ans = bitOperation.totalNQueens(16);
        end = System.currentTimeMillis();
        System.out.println("16皇后问题的答案 : " + ans);
        System.out.println("运行时间 : " + (end - start) + " 毫秒");
    }
}
